<template>
    <section id="conmonDisabled1" v-if="conmonDisabled == true">
        <el-row>
            <el-col :span="23"><div class="grid-content bg-purple">
                <el-form :inline="true" :model="formInline" ref="formInline" class="demo-form-inline">
                    <el-form-item label="影院名称">
                        <el-input v-model.trim="formInline.user" placeholder="影院名称"></el-input>
                    </el-form-item>
                     <el-form-item label="专资编码">
                        <el-input v-model.trim="formInline.user1" placeholder="专资编码"></el-input>
                    </el-form-item>
                    <el-form-item label="数据同步情况" v-if="list=='journal'">
                        <el-select v-model="formInline.user7" placeholder="数据同步情况">
                            <el-option
                                    v-for="item in user7"
                                    :key="item.codeId"
                                    :label="item.codeValue"
                                    :value="item.codeId">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item :label="list == 'workoRder'?'创单时间':listData=='trouble'?'上报时间':'信息变更时间'" v-if="list == 'workoRder'||listData=='trouble' || list=='cinema' || list=='journal' ">
                        <el-date-picker
                                v-model="formInline.user4"
                                type="datetimerange"
                                range-separator="至"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item :label="list == 'log'?'时间范围':'信息确认时间'" v-if="list=='journal'">
                        <el-date-picker
                                v-model="formInline.user5"
                                type="datetimerange"
                                range-separator="至"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="放映日期" v-if="list == 'log'">
                        <el-date-picker
                                v-model="formInline.user9"
                                type="date"
                                placeholder="选择日期时间" :picker-options="pickerOptions">
                        </el-date-picker>
                    </el-form-item>
                     <el-form-item label="工单类型" v-if="list == 'workoRder'">
                        <!-- <el-input v-model.trim="formInline.user2" placeholder="工单类型"></el-input> -->
                         <el-select v-model="formInline.user2" placeholder="请选择工单类型">
                            <el-option
                            v-for="item in user2"
                            :key="item.codeId"
                            :label="item.codeValue"
                            :value="item.codeId">
                            </el-option>
                        </el-select>
                    </el-form-item>
                     <el-form-item label="工单状态" v-if="list == 'workoRder'||list=='trouble'">
                        <!-- <el-input v-model.trim="formInline.user3" placeholder="工单状态"></el-input> -->
                         <el-tooltip class="item" effect="dark" content="查询历史故障时无法筛选工单状态，可通过工单列表查询" placement="top-start" v-if="formInline.user10==true">
                         <el-select v-model="formInline.user3" placeholder="请选择工单状态" :disabled="formInline.user10==true?true:false" >
                        <el-option
                        
                          v-for="item in user3"
                          :key="item.codeId"
                          :label="item.codeValue"
                          :value="item.codeId">
                        </el-option>
                      </el-select>
                      </el-tooltip>
                      <el-select v-model="formInline.user3" placeholder="请选择工单状态"  v-if="formInline.user10==false">
                        <el-option
                          v-for="item in user3"
                          :key="item.codeId"
                          :label="item.codeValue"
                          :value="item.codeId">
                        </el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item label="影院地址" v-if="list=='cinema'">
                        <el-input v-model.trim="formInline.user6" placeholder="影院地址"></el-input>
                    </el-form-item>
                    <el-form-item label="放映状态" v-if="list == 'status'">
                        <el-select size="small" v-model="formInline.user8" placeholder="请选择" >
                             <el-option
                                    key="未知"
                                    label="未知"
                                    value="未知">
                            </el-option>
                            <el-option
                                    key="空闲中"
                                    label="空闲中"
                                    value="空闲中">
                            </el-option>
                            <el-option
                                    key="未连接"
                                    label="未连接"
                                    value="未连接">
                            </el-option>
                            <el-option
                                    key="放映中"
                                    label="放映中"
                                    value="放映中">
                            </el-option>
                            <el-option
                                    key="停止"
                                    label="停止"
                                    value="停止">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="" v-if="list=='trouble'">
                        <el-checkbox v-model="formInline.user10">通过历史表查询</el-checkbox>
                    </el-form-item>
                    <el-form-item>
                        <el-button class="btn commonButton" @click="onSubmit(formInline)">筛选</el-button>
                       <el-button class="btn commonButton" v-if="list=='cinema'||list=='journal'" @click="resetForm('formInline',formInline)">重置</el-button>
                    </el-form-item>
                </el-form>
            </div></el-col>
            <el-col :span="1"><div class="grid-content bg-purple-light">
                <i class="el-icon-close" style="font-size: 30px;" @click="conmonDisabledNone(formInline)"></i>
                </div></el-col>
        </el-row>
    </section>
</template>
<script>
import moment from 'moment';
import Service from './form.service';
export default {
    name:'form',
    data(){
        return {
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() > moment().subtract(1, 'days');
                },
            },
            formInline: {
                user: '',
                user1: '',
                user2: '',
                user3: '',
                user4:[],
                user5:[],
                user6:'',
                user7:'',
                user8:'',
                user9:moment().subtract(1, 'days'),
                user10:false,
            },
            user2:[],
            user3:[],
            user7:[]
            // conmonDisabled:false
      }

    },
    props:['conmonDisabled','list','listData'],
    methods: {
        getShow() {
            // debugger
            this.conmonDisabled = true;
             this.formInline= {
                user: '',
                user1: '',
                user2: '',
                user3: '',
                user4:[],
                user5:[],
                user6:'',
                user7:'',
                user8:'',
                user9:'',
                user10:'',
            }
        },
        onSubmit(formInline) {
            this.$emit('condition',formInline)
        },
        conmonDisabledNone(formInline) {
            this.formInline= {
                user: '',
                user1: '',
                user2: '',
                user3: '',
                user4:[],
                user5:[],
                user6:'',
                user7:'',
                user8:'',
                user9:'',
                user10:'',
            }
            //console.log(this.formInline)
            //console.log(this.formInline.user4)

            //console.log(this.formInline.user5)

            this.$emit('conmonDisabledNone',this.formInline)
        },
        workOrderType() {
            let workOrderType = 'workOrderType'
            Service.codeListByType(workOrderType).then(res=>{
                //console.log(res)
                // this.user2 = res.data.data
                if(res.data.succeeded){
                    this.user2 = res.data.data
                }else{
                    this['$message']({
                        message: res.data.errorMessage,
                        type: 'error'
                    });
                }

            })
        },
        byType() {
             let state = 'flmPushStatus'
            Service.codeListByType(state).then(res=>{
                if(res.data.succeeded){
                    this.user7 = res.data.data
                }else{
                    this['$message']({
                        message: res.data.errorMessage,
                        type: 'error'
                    });
                }
            })
        },
        codeListByType() {
            let state = 'state'
            Service.codeListByType(state).then(res=>{
               if(res.data.succeeded){
                    this.user3 = res.data.data
                }else{
                    this['$message']({
                        message: res.data.errorMessage,
                        type: 'error'
                    });
                }
            })
        },
        resetForm(formName,formInline) {
            // this.$refs[formName].resetFields();
            this.formInline= {
                user: '',
                user1: '',
                user2: '',
                user3: '',
                user4:[],
                user5:[],
                user6:'',
                user7:'',
                user8:'',
                user9:'',
                user10:'',
            }
            this.$emit('condition', this.formInline)
        }
    },
    created(){
       this.workOrderType();
       this.codeListByType();
       this.byType();
       this.user9 = moment().subtract(1, 'days').calendar();
    },
    mounted(){

    },
}
</script>
<style scoped>
#conmonDisabled1 {
padding: 20px; background: #f5f5f5;
}
</style>
